package com.yl.pattern.behavioralmodel.observer;

import com.yl.pattern.behavioralmodel.state.before.Lift;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 小羊
 * @Date 1/11/2024下午 3:14
 * @ClassName SubscriptionSubject
 * @Description 具体主题角色类
 */
public class SubscriptionSubject implements Subject{
    private List<Observer> weiXinUserList = new ArrayList<>();
    @Override
    public void attach(Observer observer) {
        weiXinUserList.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        weiXinUserList.remove(observer);
    }

    @Override
    public void notify(String message) {
        for (Observer observer : weiXinUserList) {
            observer.update(message);
        }
    }
}
